import Vue from 'vue'
import App from './App.vue'



import HashMap from '@/common/HashMap'
Vue.prototype.hashMap=new HashMap()

// Vue.prototype.friendList=[]
//elementui使用
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)

//vue router使用
import routes from './routes'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const router = new VueRouter({
  routes
})

//vuex使用
import Vuex from 'vuex'
Vue.use(Vuex)
import store from './vuex/store'

//基于 Vue.js 的移动端组件库,http://mint-ui.github.io/#!/zh-cn
import Mint from 'mint-ui'
import 'mint-ui/lib/style.css'
Vue.use(Mint);

//对话框全屏和可拖拽
import '@/common/dialog-full-move'

//引入axios
import axios from 'axios';

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
   // debugger
    //NProgress.start();
    if (to.path == '/login') {
        sessionStorage.removeItem('mockUser');
        next();
    }
    /**
     * sessionStorage 用于临时保存同一窗口(或标签页)的数据，在关闭窗口或标签页之后将会删除这些数据
     * localStorage的生命周期是永久的，意思就是如果不主动清除，存储的数据将一直被保存
     */
    //let user = JSON.parse(localStorage.getItem('mockUser'));
    let user = JSON.parse(sessionStorage.getItem('mockUser'));
    if (user!=null&&to.path!='/login') {
        next();
    }else{
        next({path: '/login'});
    }
})



new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
